package com.yugu.util;

import java.time.LocalDate;
import java.time.Year;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class DataUtils {
	
	public static String getNO(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		 return sb.append(DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now()) +
	                (next <= 10000 ? "0" + String.valueOf(10000 + next).substring(1) : next)).toString();
	}
	public static String getNOYear(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		return sb.append(DateTimeFormatter.ofPattern("yyyy").format(Year.now()) +
				(next <= 10000 ? "0" + String.valueOf(10000 + next).substring(1) : next)).toString();
	}
	/**
	 * 获取公司代码
	 * @param pre
	 * @param next
	 * @return
	 */
	public static String getCompayNO(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		 return sb.append((next <= 10 ? "0" + String.valueOf(10 + next).substring(1) : next)).toString();
	}
	public static String getEmpNO(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		 return sb.append((next <= 1000 ? "0" + String.valueOf(1000 + next).substring(1) : next)).toString();
	}
	public static String getDriverNO(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		 return sb.append((next <= 1000 ? "0" + String.valueOf(1000 + next).substring(1) : next)).toString();
	}
	public static String geQRCode(String pre,long next) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isNotEmpty(pre)) {
			sb.append(pre).append("");
		}
		sb.append("leberking");
		return sb.append((next <= 100000000 ? "0" + String.valueOf(100000000 + next).substring(1) : next)).toString();
	}
	public static String getPickingCode() {
		Random random = new Random();
		return random.nextInt(10000)+"";
	}
//	public static String getPinYinHeadChar(String str) {
//	    String convert = "";
//	    for (int j = 0; j < str.length(); j++) {
//	          char word = str.charAt(j);
//	          String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
//	          if (pinyinArray != null) {
//	              convert += pinyinArray[0].charAt(0);
//	          } else {
//	              convert += word;
//	          }
//	      }
//	      return convert;
//	}
	public static void main(String[] args) {
//		String s="中国";
//		System.out.println(getPinYinHeadChar(s));
	}

}
